{
    let Login = document.querySelector('.Login');
    let Register = document.querySelector('.Register');
    let list = [
        document.querySelector('.username input'),
        document.querySelector('.email_address input'),
        document.querySelector('.password input'),
        document.querySelector('.password_again input')
    ];
    function debounce(fn, delay) {
        let timer = null;
        return function () {
            if (timer) {
                clearTimeout(timer);
            }
            timer = setTimeout(fn, delay);
        };
    }
    Login.addEventListener('click', debounce(function () {
        const requestData = {
            username: list[0].value,
            password: list[2].value
        };
        var config = {
            method: 'post',
            url: 'https://my-json-server.typicode.com/INGOT-ZHOU/MYFAKEAPI',
            headers: {
                'Content-Type': 'application/json',
            },
            data: JSON.stringify(requestData)
        };
        console.log("LOGIN DATA:", requestData);
        axios(config)
            .then(function (response) {
                console.log(JSON.stringify(response.data));
            })
            .catch(function (error) {
                if (error.response) {
                    console.log(error.response.status);
                }
            });
    }, 2000));
    Register.addEventListener('click', debounce(function () {
        const requestData = {
            username: list[0].value,
            email_address:list[1].value,
            password: list[2].value
        };
        var config = {
            method: 'post',
            url: 'https://my-json-server.typicode.com/INGOT-ZHOU/MYFAKEAPI',
            headers: {
                'Content-Type': 'application/json',
            },
            data: JSON.stringify(requestData)
        };
        console.log("REGISTER DATA:", requestData);
        axios(config)
            .then(function (response) {
                console.log(JSON.stringify(response.data));
            })
            .catch(function (error) {
                if (error.response) {
                    console.log(error.response.status);
                }
            });
    }, 2000));
}